package com.hankol.newretail.adapter

import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.baselibrary.Constants
import com.baselibrary.extension.checkValue
import com.baselibrary.router.ActivityRouter
import com.baselibrary.utils.ARouterUtils
import com.baselibrary.utils.GlideUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.hankol.newretail.R
import com.hankol.newretail.bean.EvaluationBean
import com.hankol.newretail.bean.NeedEvaluationBean

/**
 * @author: 关忆北、
 * @date: 2022/8/8
 * @Des：待评价列表
 */
class NeedEvaluateListAdapter : BaseQuickAdapter<NeedEvaluationBean, BaseViewHolder>(R.layout.item_need_evaluate_list) {

    override fun convert(helper: BaseViewHolder, item: NeedEvaluationBean) {
        helper.setText(R.id.tv_order_store_name, item.shopName)
        helper.getView<TextView>(R.id.tv_order_store_name).setOnClickListener {//进入酒窖详情
            val hashMap = HashMap<String, Any>()
            hashMap["id"] = "${item.shopId}"
            hashMap["dealerCode"] = "${item.dealerCode}"
            ARouterUtils.jump(ActivityRouter.WINE_CELLAR.WINCE_CELLAR_DETAIL, hashMap)
        }
        val needEvaluateChildAdapter = NeedEvaluateChildAdapter()
        val recycleView = helper.getView<RecyclerView>(R.id.rv_need_evaluate)
        needEvaluateChildAdapter.setNewData(item.needList)
        needEvaluateChildAdapter.setOnItemClickListener { _, _, position ->
            //进入商品详情
            val map = HashMap<String, Any>()
            map[Constants.GOODS_DETAIL_ID] = item.needList[position].spuId
            map[Constants.GOODS_SKU_ID] = item.needList[position].skuId
            map[Constants.GOODS_DETAIL_SOURCE] = "评价列表"
            ARouterUtils.jump(ActivityRouter.NEW_RETAIL.GOODS_DETAUILS, map)
        }
        needEvaluateChildAdapter.setOnItemChildClickListener { _, _, position ->
            val hashMap = HashMap<String, Any>()
            hashMap["productInfoId"] = item.needList[position].productInfoId
            ARouterUtils.jump(ActivityRouter.NEW_RETAIL.PUBLISH_EVALUATION, hashMap)
        }
        recycleView.adapter = needEvaluateChildAdapter

    }

    class NeedEvaluateChildAdapter : BaseQuickAdapter<EvaluationBean, BaseViewHolder>(R.layout.item_need_evaluate_child_list) {
        override fun convert(helper: BaseViewHolder, item: EvaluationBean) {
            GlideUtils.loadImg_228(mContext, item.skuCover, helper.getView(R.id.round_order_cover))
            helper.setText(R.id.tv_order_title, item.spuName.checkValue())
            helper.setText(R.id.tv_reward_number, item.rewardScore.toString())
            helper.addOnClickListener(R.id.tv_go_evaluate)
        }

    }

}

